﻿using Dotnet.DB.SQLite;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sui.Domain.App
{
    public class AppBase
    {
        protected static SQLite db = new SQLite("data.db");
        protected static DbConnection conn = db.Connection;

        public virtual DataTable GetDataTable(string tabName)
        {
            string strSql = $"select *from {tabName}";
            DbCommand cmd = db.GetSqlStringCommond(strSql);
            DataTable dt = db.ExecuteDataTable(cmd);
            return dt;
        }
        public virtual DataTable GetDataTableBySql(string strSql)
        {
            //string strSql = $"select *from {tabName}";
            DbCommand cmd = db.GetSqlStringCommond(strSql);
            DataTable dt = db.ExecuteDataTable(cmd);
            return dt;
        }

        public virtual int Update(string strSql)
        {
            DbCommand cmd = db.GetSqlStringCommond(strSql);
            int ret = db.ExecuteNonQuery(cmd);
            return ret;
        }
    }
}
